package com.siwei.mes.dto;

import com.siwei.mes.common.validator.auth.LoginCaptcha;
import com.siwei.mes.common.validator.auth.LoginCode;
import com.siwei.mes.common.validator.auth.LoginGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @Description: 登录用户信息
 * @Version: 1.0
 * @author: chenmaolin
 * @date: 2023/11/21 19:13
 */
@Data
public class AuthUser {
    @NotBlank(message = "手机号为空", groups = {LoginGroup.class, LoginCaptcha.class, LoginCode.class})
    @Size(max = 11, min = 11, message = "请输入正确的手机号", groups = {LoginGroup.class, LoginCaptcha.class, LoginCode.class})
    @Pattern(regexp = "^1[3456789]\\d{9}$", message = "请输入正确的手机号", groups = {LoginGroup.class, LoginCaptcha.class, LoginCode.class})
    private String userPhone;

    @NotBlank(message = "密码为空", groups = {LoginCaptcha.class})
    @ApiModelProperty(value = "密码")
    private String password;


    @ApiModelProperty(value = "登录端  PC/APP")
    private String driver;

    public String getDriver() {
        return StringUtils.isBlank(driver) ? "PC" : driver;
    }
}
